package com.example.demo.tool.archery;

import cn.hutool.json.JSONArray;
import lombok.RequiredArgsConstructor;

import lombok.extern.slf4j.Slf4j;

/**
 * @author jiangjinwu
 * @version 1.0
 * @since 2025/10/24 20:42
 */

@Slf4j
public class SqlResultStrategy<T> implements ResultStrategy{
    @Override
    public String getData(NestResultContainer nestResultContainer) {
        StringBuilder sb = new StringBuilder();
        int index = nestResultContainer.getColumnIndex(nestResultContainer.getIdColumn());
        sb.append("(");
        var data =nestResultContainer.getData();
        for (int i = 0; i < data.size(); i++) {
            JSONArray row = (JSONArray) data.get(i);
            sb.append(row.get(index));
            if (i != data.size() - 1) {
                sb.append(",");
            }
        }
        sb.append(")");
        return sb.toString();
    }
}
